
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="assets/ico/favicon.ico" type="image/x-icon" />
    <link href="assets/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/jquery.mmenu.css" rel="stylesheet">
    <link href="assets/css/font-awesome.min.css" rel="stylesheet">
    <link href="assets/plugins/jquery-ui/css/jquery-ui-1.10.4.min.css" rel="stylesheet">
    <link href="assets/css/style.min.css" rel="stylesheet">
    <link href="assets/css/add-ons.min.css" rel="stylesheet">
    <title>出库管理</title>
</head>
<style type="text/css">
    #a{
        text-decoration:none;
    }
</style>
<body>
<div class="row">
    <div class="col-lg-10">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h2><i class="fa fa-table red"></i><span class="break"></span><strong>出库管理</strong></h2>
                <!--<div class="panel-actions">-->
                <!--<a href="table.html#" class="btn-setting"><i class="fa fa-rotate-right"></i></a>-->
                <!--<a href="table.html#" class="btn-minimize"><i class="fa fa-chevron-up"></i></a>-->
                <!--<a href="table.html#" class="btn-close"><i class="fa fa-times"></i></a>-->
                <!--</div>-->
                <input type="hidden" name="method" value="search">
                <input type="text" name="keyword" title="请输入配件名称">
                <input type="button" class="fuzzyquery" value="搜索">
            </div>
            <div class="panel-body">
                <table class="table">
                    <thead>
                    <tr>
                        <th>出库编号</th>
                        <th>出库人</th>
                        <th>出库时间</th>
                        <th>服务类型</th>
                        <th>配件编号</th>
                        <th>配件名称</th>
                        <th>配件数量</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody id="TableData" class="datas">
                    </tbody>
                </table>
                <div id="TableTail" align="center">
                </div>
            </div>
        </div>
    </div><!--/col-->

</div><!--/row-->
</body>
<script type="text/javascript" src="assets/js/jquery-1.8.3.min.js"></script>
<script type="text/javascript">
    //定义方法发送ajax向后台发送数据
    $(function () {
        getDatas("","");
        //模糊查询
        $(".fuzzyquery").bind("click",function () {
            var condition = $("input[name=keyword]").val();
            var pageNum = 1;
            getDatas(pageNum,condition);
        });
        //首页
        $(document).on("click",".homepage",function() {
            var condition = $("input[name=keyword]").val();
            var pageNum = 1;
            getDatas(pageNum,condition);
        });
        //下一页
        $(document).on("click",".nextpage" ,function() {
            var condition = $("input[name=keyword]").val();
            var pageNum = $(".pageNum").text();
            pageNum = parseInt(pageNum);
            var pages = $(".pages").text();
            pages = parseInt(pages);
            if (pageNum==undefined){
                pageNum=1;
            }else if (pageNum>=pages){
                pageNum=pages;
            }else {
                pageNum = pageNum+1;
            }
            getDatas(pageNum,condition);
        });
        //上一页
        $(document).on("click",".previouspage",function () {
            var condition = $("input[name=keyword]").val();
            var pageNum = $(".pageNum").text();
            pageNum = parseInt(pageNum);
            if (pageNum==undefined || pageNum<=1){
                pageNum=1;
            }else {
                pageNum = pageNum-1;
            }
            getDatas(pageNum,condition);
        });
        //尾页
        $(document).on("click",".trailerpage",function () {
            var condition = $("input[name=keyword]").val();
            var pages = $(".pages").text();
            pages = parseInt(pages);
            if (pages==undefined){
                pages=1;
            }
            getDatas(pages,condition);
        });
        function getDatas(pageNum,condition) {
            $(".datas").empty();
            $("#TableTail").empty();
            $.ajax({
                url:"/SpareoutselectAll",
                data:{"pageNum":pageNum,"condition":condition},
                type:"post",
                dataType:"json",
                success:function (data) {
                    console.log(data);
                    if (data.list){
                        var dessert = data.list;
                        for (var i=0;i<dessert.length;i++){
                            var de = dessert[i];
                            $(".datas").append("<tr class='TableDetail1'><td>"+de.spareoutid+"</td><td>"+de.spareoutname
                                +"</td><td>"+de.spareouttime+"</td><td>"+de.spareoutbywhy
                                +"</td><td>"+de.fkspareinventoryid.spareinventoryid
                                +"</td><td>"+de.fkspareinventoryid.spareinventorybrand+"</td><td>"+de.spareoutcount
                                +"</td><td><button><a href='/SpareoutdeleteById?spareoutid="+de.spareoutid+"' id='a' onclick='return del()'>删除</a></button></td></tr>");
                        }
                        $("#TableTail").append("<tr><td align='center'><span>共"+data.total+"条数据</span>&emsp;<span class='pageNum'>"+data.pageNum+"</span>/<span class='pages'>"+data.pages+"</span>&emsp;&emsp;&emsp;<a href='javascript:void(0);' id='a' class='homepage'>首页</a>&emsp;<a href='javascript:void(0);' id='a' class='nextpage'>下一页</a>&emsp;<a href='javascript:void(0);' id='a' class='previouspage'>上一页</a>&emsp;<a href='javascript:void(0);' id='a' class='trailerpage'>尾页</a></td></tr>");
                    }
                    else {
                        $(".datas").append("<tr class='TableDetail1'><td>还没有数据哦...</td></tr>");
                    }
                }
            });
        }
    });
    function del() {
        if (confirm("确定要删除吗？")) {
            return true;
        } else {
            return false;
        }
    }
</script>
</html>